package com.project.fortuneteller.controller;

import com.project.fortuneteller.common.QueryPageSearchBean;
import com.project.fortuneteller.mappers.LearnContentMapper;
import com.project.fortuneteller.service.impl.LearnServiceImpl;
import com.project.fortuneteller.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 *  学习板块
 */
@Slf4j
@CrossOrigin
@RestController
@RequestMapping
public class LearnController {
  @Resource
  public LearnServiceImpl learnService;

  @Resource
  public LearnContentMapper learnContentMapper;

 /**
  * 通过 书籍名称 获取 文章的全部信息
  * @param name
  * @return
  */
  @RequestMapping("/contents")
  public Result getContentsByBookName(String name){
    // 获取文章的全部信息
    return learnService.getBookContents(name);
  }
 /**
  * 获取具体文章的信息
  * @param id
  * @return
  */
 @RequestMapping("/content")
 public Result getContentById(String id){
    // 获取文章信息
    return learnService.getContentById(id);
 }

    /**
     * 查找相关的学习内容
     * @param queryPageSearchBean
     * @return
     */
 @RequestMapping("/search")
 public Result learnSearch(@RequestBody QueryPageSearchBean queryPageSearchBean){
     return learnService.searchLike(queryPageSearchBean);
 }



}
